package com.yyrj.spring;

import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UtilsDatePropertyEditor extends PropertyEditorSupport {

	private String format = null;

	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		System.out
				.println("UtilsDatePropertyEditor----setAsText-------" + text);
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		try {
			Date d = sdf.parse(text);
			this.setValue(d);
		} catch (ParseException e) {

			e.printStackTrace();
		}

	}

	public void setFormat(String format) {
		this.format = format;
	}

}
